package com.d3works.apps.account.service;

import com.d3works.apps.account.db.Account;
import com.d3works.apps.account.db.Move;
import com.d3works.apps.base.db.Partner;
import com.d3works.apps.base.db.Year;
import com.d3works.exception.D3worksException;
import com.google.inject.persist.Transactional;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;

public interface AccountingCloseAnnualService {

  @Transactional(rollbackOn = {D3worksException.class, RuntimeException.class})
  public List<Move> generateCloseAndOpenAnnualAccount(
      Year year,
      Account account,
      Partner partner,
      LocalDate endOfYearDate,
      LocalDate reportedBalanceDate,
      String origin,
      String moveDescription,
      boolean closeYear,
      boolean openYear,
      boolean allocatePerPartner)
      throws D3worksException;

  @Transactional(rollbackOn = {D3worksException.class, RuntimeException.class})
  public List<Move> generateCloseAnnualAccount(
      Year year,
      Account account,
      Partner partner,
      LocalDate endOfYearDate,
      LocalDate reportedBalanceDate,
      String origin,
      String moveDescription,
      boolean closeYear,
      boolean allocatePerPartner)
      throws D3worksException;

  @Transactional(rollbackOn = {D3worksException.class, RuntimeException.class})
  public List<Move> generateOpenAnnualAccount(
      Year year,
      Account account,
      Partner partner,
      LocalDate endOfYearDate,
      LocalDate reportedBalanceDate,
      String origin,
      String moveDescription,
      boolean openYear,
      boolean allocatePerPartner)
      throws D3worksException;

  public List<Long> getAllAccountOfYear(Set<Account> accountSet, Year year);

  public List<Pair<Long, Long>> assignPartner(
      List<Long> accountIdList, Year year, boolean allocatePerPartner);
}
